#include <QGuiApplication>
#include <QQmlApplicationEngine>

#include "openglItem.h"

int main(int argc, char *argv[])
{
    //QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    QGuiApplication app(argc, argv);

    qmlRegisterType<OpenGLItem>("OpenGLItem", 1, 0, "OpenGLItem");

    QQmlApplicationEngine engine;
    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);


    QObject *rootObject = engine.rootObjects().first();
    if(rootObject)
    {
        // 搜索所有QML下的控件
        QList<QQuickItem*> allItems = rootObject->findChildren<QQuickItem*>();

        // 遍历输出找到的控件
        for (QQuickItem* item : allItems)
        {
            if(item->objectName() == "adas")
            {
                OpenGLItem* obj = qobject_cast<OpenGLItem *>(item);
                if(obj)
                {
                    //obj->on_timeOut();
                }
            }
        }
    }



    return app.exec();
}
